var t = require("../../../../@babel/runtime/helpers/slicedToArray"), e = require("../../../../common/vendor.js"), i = require("../../../uv-ui-tools/libs/mixin/mpMixin.js"), o = require("../../../uv-ui-tools/libs/mixin/mixin.js");

require("../../../uv-ui-tools/libs/function/index.js"), require("../../../uv-ui-tools/libs/function/test.js"), 
require("../../../uv-ui-tools/libs/function/digit.js"), require("../../../uv-ui-tools/libs/util/route.js"), 
require("../../../uv-ui-tools/libs/function/debounce.js"), require("../../../uv-ui-tools/libs/function/throttle.js");

var n = {
    name: "uv-list-item",
    mixins: [ i.mpMixin, o.mixin ],
    emits: [ "click", "switchChange" ],
    props: {
        direction: {
            type: String,
            default: "row"
        },
        title: {
            type: String,
            default: ""
        },
        note: {
            type: String,
            default: ""
        },
        ellipsis: {
            type: [ Number, String ],
            default: 0
        },
        disabled: {
            type: [ Boolean, String ],
            default: !1
        },
        clickable: {
            type: Boolean,
            default: !1
        },
        showArrow: {
            type: [ Boolean, String ],
            default: !1
        },
        link: {
            type: [ Boolean, String ],
            default: !1
        },
        to: {
            type: String,
            default: ""
        },
        showSwitch: {
            type: [ Boolean, String ],
            default: !1
        },
        switchChecked: {
            type: [ Boolean, String ],
            default: !1
        },
        showBadge: {
            type: [ Boolean, String ],
            default: !1
        },
        badge: {
            type: Object,
            default: function() {
                return {};
            }
        },
        rightText: {
            type: String,
            default: ""
        },
        thumb: {
            type: String,
            default: ""
        },
        thumbSize: {
            type: String,
            default: "base"
        },
        showExtraIcon: {
            type: [ Boolean, String ],
            default: !1
        },
        extraIcon: {
            type: Object,
            default: function() {
                return {
                    name: "",
                    color: "#000000",
                    size: 20,
                    customPrefix: ""
                };
            }
        },
        border: {
            type: Boolean,
            default: !1
        },
        customStyle: {
            type: Object,
            default: function() {
                return {
                    padding: "",
                    backgroundColor: "#FFFFFF"
                };
            }
        },
        keepScrollPosition: {
            type: Boolean,
            default: !1
        }
    },
    computed: {
        directionData: function() {
            return this.direction ? this.direction : this.parentData.direction ? this.parentData.direction : "row";
        }
    },
    watch: {
        "customStyle.padding": {
            handler: function(t) {
                t && this.setPadding(t);
            },
            immediate: !0
        }
    },
    data: function() {
        return {
            isFirstChild: !1,
            padding: {
                top: "",
                right: "",
                bottom: "",
                left: ""
            },
            parentData: {
                direction: "row",
                padding: 0
            }
        };
    },
    created: function() {
        this.updateParentData();
    },
    mounted: function() {
        this.init(), this.list = this.getForm(), this.list && (this.list.firstChildAppend || (this.list.firstChildAppend = !0, 
        this.isFirstChild = !0));
    },
    methods: {
        init: function() {
            var t = this;
            this.parent || this.$uv.error("uv-list-item必须搭配uv-list组件使用"), this.$nextTick(function() {
                t.padding.top || t.padding.right || t.padding.bottom || t.padding.left || t.setPadding(t.parentData.padding);
            });
        },
        updateParentData: function() {
            this.getParentData("uv-list");
        },
        setPadding: function(e) {
            "number" == typeof e && (e += "");
            var i = e.split(" ");
            if (1 === i.length) {
                var o = i[0];
                this.padding = {
                    top: o,
                    right: o,
                    bottom: o,
                    left: o
                };
            } else if (2 === i.length) {
                var n = t(i, 2), a = n[0], r = n[1];
                this.padding = {
                    top: a,
                    right: r,
                    bottom: a,
                    left: r
                };
            } else if (4 === i.length) {
                var s = t(i, 4), l = s[0], u = s[1], d = s[2], c = s[3];
                this.padding = {
                    top: l,
                    right: u,
                    bottom: d,
                    left: c
                };
            }
        },
        getForm: function() {
            for (var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "uniList", e = this.$parent, i = e.$options.name; i !== t; ) {
                if (!(e = e.$parent)) return !1;
                i = e.$options.name;
            }
            return e;
        },
        onClick: function() {
            "" === this.to ? (this.clickable || this.link) && this.$emit("click", {
                data: {}
            }) : this.openPage();
        },
        onSwitchChange: function(t) {
            this.$emit("switchChange", t);
        },
        openPage: function() {
            -1 !== [ "navigateTo", "redirectTo", "reLaunch", "switchTab" ].indexOf(this.link) ? this.pageApi(this.link) : this.pageApi("navigateTo");
        },
        pageApi: function(t) {
            var i = this, o = {
                url: this.to,
                success: function(t) {
                    i.$emit("click", {
                        data: t
                    });
                },
                fail: function(t) {
                    i.$emit("click", {
                        data: t
                    });
                }
            };
            switch (t) {
              case "navigateTo":
              default:
                e.index.navigateTo(o);
                break;

              case "redirectTo":
                e.index.redirectTo(o);
                break;

              case "reLaunch":
                e.index.reLaunch(o);
                break;

              case "switchTab":
                e.index.switchTab(o);
            }
        }
    }
};

Array || (e.resolveComponent("uv-icon") + e.resolveComponent("uv-badge") + e.resolveComponent("uv-switch"))(), 
Math || (function() {
    return "../../../uv-icon/components/uv-icon/uv-icon.js";
} + function() {
    return "../../../uv-badge/components/uv-badge/uv-badge.js";
} + function() {
    return "../../../uv-switch/components/uv-switch/uv-switch.js";
})();

var a = e._export_sfc(n, [ [ "render", function(t, i, o, n, a, r) {
    return e.e({
        a: !a.isFirstChild
    }, a.isFirstChild ? {} : {
        b: o.border ? 1 : ""
    }, {
        c: o.thumb
    }, o.thumb ? {
        d: o.thumb,
        e: e.n("uv-list--" + o.thumbSize)
    } : o.showExtraIcon ? {
        g: e.p({
            name: o.extraIcon.icon,
            customPrefix: o.extraIcon.customPrefix,
            color: o.extraIcon.color,
            size: o.extraIcon.size
        })
    } : {}, {
        f: o.showExtraIcon,
        h: o.title
    }, o.title ? {
        i: e.t(o.title),
        j: e.n(o.ellipsis && "uv-line-".concat(o.ellipsis))
    } : {}, {
        k: o.note
    }, o.note ? {
        l: e.t(o.note)
    } : {}, {
        m: o.thumb || o.showExtraIcon || o.showBadge || o.showSwitch ? 1 : "",
        n: o.rightText || o.showBadge || o.showSwitch
    }, o.rightText || o.showBadge || o.showSwitch ? e.e({
        o: o.rightText
    }, o.rightText ? {
        p: e.t(o.rightText)
    } : {}, {
        q: o.showBadge
    }, o.showBadge ? {
        r: e.p({
            show: !!(o.badge.show || o.badge.isDot || o.badge.value),
            isDot: o.badge.isDot,
            value: o.badge.value,
            max: o.badge.max,
            type: o.badge.type,
            showZero: o.badge.showZero,
            bgColor: o.badge.bgColor,
            color: o.badge.color,
            shape: o.badge.shape,
            numberType: o.badge.numberType,
            inverted: o.badge.inverted,
            customStyle: "margin-left: 4px;"
        })
    } : {}, {
        s: o.showSwitch
    }, o.showSwitch ? {
        t: e.o(r.onSwitchChange),
        v: e.p({
            value: o.switchChecked,
            disabled: o.disabled
        })
    } : {}, {
        w: "column" === r.directionData ? 1 : ""
    }) : {}, {
        x: o.showArrow || o.link ? 1 : "",
        y: "column" === r.directionData ? 1 : "",
        z: a.padding.top,
        A: a.padding.left,
        B: a.padding.right,
        C: a.padding.bottom,
        D: o.showArrow || o.link
    }, o.showArrow || o.link ? {
        E: e.p({
            size: "34rpx",
            color: "#bbb",
            name: "arrow-right"
        })
    } : {}, {
        F: o.disabled ? 1 : "",
        G: e.s(t.$uv.addStyle(o.customStyle)),
        H: e.s({
            "background-color": o.customStyle.backgroundColor ? o.customStyle.backgroundColor : "#fff"
        }),
        I: !o.clickable && !o.link || o.disabled || o.showSwitch ? "" : "uv-list-item--hover",
        J: e.o(function() {
            return r.onClick && r.onClick.apply(r, arguments);
        })
    });
} ], [ "__scopeId", "data-v-b0795907" ] ]);

wx.createComponent(a);